//
//  FindViewController.m
//  Home
//
//  Created by 杨泓晔 on 16/4/8.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "FindViewController.h"
#import "YHYExpertFindViewCell.h"
#import "YHYDetailViewController.h"
#import "YHYAnimationDemo.h"
#import "WUVippViewController.h"
#import "YHYFindSearchViewController.h"
@interface FindViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,retain)UITableView *myTableView;
@property (nonatomic,retain)WSCustomButton *singin, *SSbution;
@property (nonatomic,retain) UILabel *balabel;
@end

@implementation FindViewController
- (void)viewWillAppear:(BOOL)animated {
    
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.translucent = NO;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatView];
    self.navigationController.navigationBar.barTintColor = HEADVC;
    
    self.view.backgroundColor=LV;
    
    //圆圈
    self.singin=[[WSCustomButton alloc]init];
    [self.singin setImage:[[UIImage imageNamed:@"QQ"]  imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
    self.singin.frame=CGRectMake(0, 0, 30 *AUTO_WIDTH, 30*AUTO_HEIGHT);
    [self.singin addTarget:self action:@selector(singinAction:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:_singin];
    
    
    //100
    _balabel=[[UILabel alloc]init];
    _balabel.text=@"100";
    _balabel.textColor=[UIColor whiteColor];
    _balabel.textAlignment=NSTextAlignmentLeft;
    _balabel.font=[UIFont fontWithName:TFont size:TEXTCONTENTFONT * AUTO_WIDTH];
    [_singin addSubview:_balabel];
    [_balabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_singin).offset(5 *AUTO_HEIGHT);
        make.left.equalTo(_singin).offset(0);
        make.size.mas_equalTo(CGSizeMake(28*AUTO_WIDTH, 20*AUTO_HEIGHT));
    }];
    
    
    //右边按钮
    self.SSbution = [WSCustomButton buttonWithType:UIButtonTypeCustom];
    self.SSbution.frame = CGRectMake(0, 0, 30, 30);
    
    [self.SSbution setImage:[[UIImage imageNamed:@"搜索"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
    // self.SSbution.backgroundColor = [UIColor whiteColor];
    [self.SSbution addTarget:self action:@selector(souSuo:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_SSbution];
    
    
}
- (void)creatView{
    
    YHYAnimationDemo *naView = [[YHYAnimationDemo alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40 * AUTO_WIDTH)];
    [self.view addSubview:naView];

    
    _myTableView = [UITableView new];
    _myTableView.backgroundColor = LV;
    [self.view addSubview:_myTableView];
    [_myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(40 * AUTO_HEIGHT);
        make.left.mas_equalTo(0 * AUTO_WIDTH);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(self.view.mas_bottom).offset(-50 * AUTO_HEIGHT);
        
    }];
    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    
    
    
    [_myTableView registerClass:[YHYExpertFindViewCell class] forCellReuseIdentifier:@"YHYFindViewCell"];
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *str = @"YHYFindViewCell";
    YHYExpertFindViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str forIndexPath:indexPath];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 750/3 * AUTO_HEIGHT;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    YHYDetailViewController *detail = [YHYDetailViewController new];
    [self.navigationController pushViewController:detail animated:YES];
}
#pragma mark 搜索
- (void)souSuo:(UIButton *)sousuo{
  
    //NSLog(@"搜索按钮被点击了");
    
    YHYFindSearchViewController *find = [YHYFindSearchViewController new];
    [self.navigationController pushViewController:find animated:YES];
    
}


-(void) singinAction:(UIButton *) btn
{
    WUVippViewController *vipp=[[WUVippViewController alloc]init];
    [self.navigationController pushViewController:vipp  animated:YES];
}
@end
